/**
 *  启动并注册Canvas
 * */

import React from 'react';
import { Engine } from '../DesignerModels';

export const useCanvas = (props: Engine | null | undefined, id: string) => {
  React.useEffect(() => {
    let canvasLayout = document
      .getElementById(id)
      ?.getElementsByTagName('canvas');
    if (canvasLayout && canvasLayout.length === 1) {
      //防止注册多个画布
      return;
    } else {
      props?.initCanvas();
    }
  }, [id]);
};
